package com.by.controller;

import com.by.bean.Leave;
import com.by.bean.PageBean;
import com.by.bean.ResultBean;
import com.by.service.OaLeaveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

//@CrossOrigin解决跨域
@RestController//声明为控制类
public class OaLeaveController extends BaseController{
    @Autowired
    OaLeaveService leaveService;
    @PostMapping("/leave")//声明请求方式和路径
    public ResultBean save(@RequestBody Leave leave){
        int rs=leaveService.save(leave);
        return rs == 1 ? success("保存成功") : fail("保存失败");
    }
    @PostMapping("/leave/list")
    public ResultBean query(@RequestBody Map map){
        PageBean bean=leaveService.query(map);
        return success("请假列表",bean);
    }
}
